package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.CardTypeDto;
import edu.suda.xsap.dto.convert.CardTypeConvert;
import edu.suda.xsap.mapper.CardTypeMapper;
import edu.suda.xsap.service.CardTypeService;
import edu.suda.xsapadminutils.common.Result;
import edu.suda.xsapadminvo.CardTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CardTypeServiceImpl implements CardTypeService {

    @Autowired
    private CardTypeMapper cardTypeMapper;

    @Autowired
    private CardTypeConvert cardTypeConvert;
    @Override
    public Result save(CardTypeVO cardTypeVO) {
        cardTypeMapper.save(cardTypeVO);
        return Result.success();
    }

    @Override
    public Result update(CardTypeVO cardTypeVO) {
        cardTypeMapper.update(cardTypeVO);
        return Result.success();
    }

    @Override
    public List<CardTypeDto> findAll() {
        return cardTypeConvert.toDtoList(cardTypeMapper.findAll());
    }
}
